import {mapGetters} from 'vuex'
export default {
	computed: {
		...mapGetters('m_cart', ['total'])
	},
	
	methods: {
		// 设置tabbar的购物车徽标
		setBadge() {
			uni.setTabBarBadge({
			  index: 2,
				// text要求为字符串,隐式转换
			  text: this.total + ''
			})
		}
	},
	
	watch: {
		total() {
			this.setBadge()
		}
	},
	
	onShow() {
		// 页面加载显示徽标
		this.setBadge()
	}
}